/* eslint-disable no-debugger */
/* eslint-disable react/function-component-definition */
/**
 * CheckBox列表
 * 组件描述：根据入参以列表形式显示CheckBox，点选CheckBox实时返回被选中项。
 * @author LiAnqi
 * @Date 2022.2.23
 */

import React from 'react'
import { List, Checkbox } from 'antd'

const CheckboxList = (props) => {
  const { dataSource, onChange, propName } = props
  return (
    <List
      dataSource={dataSource}
      renderItem={(item, index) => (
        <List.Item key={item.key}>
          <List.Item.Meta title={item.title} description={item.key} />
          <div>
            <Checkbox
              checked={item[propName]}
              onChange={(e) => {
                onChange(e, index)
              }}
            />
          </div>
        </List.Item>
      )}
    />
  )
}

export default CheckboxList
